package org.tloss.web.editor.database.editors;

import org.eclipse.jface.viewers.ITreeContentProvider;
import org.eclipse.jface.viewers.Viewer;
import org.tloss.web.editor.model.Database;

public class DatabaseConfigContentProvider implements ITreeContentProvider {

	Database database;

	public DatabaseConfigContentProvider(Database database) {
		this.database = database;
		_config = new Object[] {
				new DatabaseConfig(DatabaseConfig.JDBCURL, database),
				new DatabaseConfig(DatabaseConfig.JDBCUSERNAME, database),
				new DatabaseConfig(DatabaseConfig.JDBCPASSWORD, database),
				new DatabaseConfig(DatabaseConfig.JDBCLIB, database),
				new DatabaseConfig(DatabaseConfig.DRIVERCLASS, database),
				new DatabaseConfig(DatabaseConfig.ONFFLINE_MODE, database)
				};
	}

	@Override
	public void dispose() {

	}

	@Override
	public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {

	}

	@Override
	public Object[] getElements(Object inputElement) {
		return getChildren(inputElement);
	}

	public static Object[] _config;

	@Override
	public Object[] getChildren(Object parentElement) {
		if (parentElement instanceof Database) {
			return _config;
		}
		return null;
	}

	@Override
	public Object getParent(Object element) {
		return null;
	}

	@Override
	public boolean hasChildren(Object element) {
		if (element instanceof Database) {
			return true;
		}
		return false;
	}

}
